package 算法.字节;

import java.util.Scanner;

/**
 * @author:谢君臣
 * @Date:2021/8/24-14:34
 * @version:1.0
 * @function:
 */
public class zj01 {
    private static int T = 1000000007;
    public static void main(String[] args) {
        int i = 707517223;
        System.out.println(i);
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] arr = new int[n+1];
        int[]dp = new int[n+1];
         i =1;
        while (i<n)arr[i++] = scanner.nextInt();
        for (i = 1; i < n+1 ;i++) {
            dp[i] = dp[i-1]+(dp[i-1]-dp[arr[i-1]-1]+1)+1;
        }
        System.out.println(dp[n]%T);
    }
}
